/*
 * Created on Sep 19, 2005 12:55:27 PM
 * 
 * $Id$
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package tripleo.fmsys;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;


public class fmsystem {

	private FSAccess access;
	public int xmlport=1982; // TODO
	public String xmlhost = "localhost"; // TODO

	public fmsystem(FSAccess aAccess) {
		access = aAccess;
	}

	/**
	 * Create a new component
	 *  
	 * @param aString a URI to the component
	 * @return
	 * @throws IOException 
	 */
	public FMResponse<fmcmpt> component(String aString) throws IOException {
		FMRequest req = request(Requests.CREATE);
		ByteBuffer x = ByteBuffer.allocateDirect(4096);
		x.putInt(0xDEADCAFE);
		x.putInt(req.code().ordinal());
		x.put(aString.getBytes("utf8"));
		req.write(x);
		return req.send();
	}

	public FMRequest request(Requests aCall) {
		return new FMRequest(this, aCall);
	}

}

